<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<table class="table table-condensed table-bordered" style="width: 50%">
	<tr>
		<th>名称</th>
		<th>域名</th>
	</tr>
		<tr dataid=${domain.id }>
			<td id="domain_name">${domain.name }</td>
			<td id="domain_site">${domain.domain }</td>
		</tr>
</table>

<script type="text/javascript">
$(document).ready(function() {
	$("td").click(tdclick); 
	
});
function tdclick(){  
    
    var td = $(this);  
    var text = td.text().trim();  
    td.html("");
    var input = $("<input type='text'>");  
    input.attr("value",text);  
    input.keyup(function(event){  
        var myEvent = event || window.event;  
        var key = myEvent.keyCode;  
        if(key == 13){  
            var inputNode = $(this);  
            var inputText = inputNode.val();  
            inputNode.parent().html(inputText);  
            td.click(tdclick);  
            ajaxCommit()
        }  
    });  
    input.blur(function(){  
        var inputNode = $(this);  
        var inputText = inputNode.val();  
        inputNode.parent().html(text);  
        td.click(tdclick);  
    });  
      
    td.append(input);  
    td.unbind("click");  
}  
function ajaxCommit(){
	 var id=${domain.id};
     var name=$("#domain_name").html();
     var domain=$("#domain_site").html();
     $.post("/domain/save",{id:id,name:name,domain:domain},function(res){
     	if(res=='success'){
     		alert("修改成功");
     	}else{
     		alert("修改失败");
     	}
     });
}

</script>
